//
//  WorkOrder.m
//
//  Created by Olof Millberg on 2010-03-22.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <AddressBook/AddressBook.h>
#import "WorkOrder.h"
#import "WOPerson.h"

@implementation WorkOrder

@synthesize workID;
@synthesize description;
@synthesize checklistType;
@synthesize status;
@synthesize priority;
@synthesize customer;
@synthesize entryDate;
@synthesize endDate;
@synthesize address;
@synthesize employees;
@synthesize contactPersons;
@synthesize workLeaders;
@synthesize attachedFiles;
@synthesize historyEntries;			
@synthesize addedHistoryEntries;
@synthesize updatedHistoryEntries;
@synthesize timeReports;
@synthesize addedTimeReports;
@synthesize updatedTimeReports;
@synthesize checklistPoints;
@synthesize timeTypes;
@synthesize statusTypes;
@synthesize priorityTypes;

-(id)initWithWorkID:(NSInteger) aWorkID
		description:(NSString *) aDescription
	  checklistType:(NSString *) aChecklistType 
			 status:(NSString *) aStatus 
		   priority:(NSString *) aPriority 
		   customer:(NSString *) aCustomer
		  entryDate:(NSDate *) anEntryDate 
			endDate:(NSDate *) anEndDate
			address:(WOAddress *) anAddress 
		  employees:(NSMutableArray *) someEmployees
	 contactPersons:(NSMutableArray *) someContactPersons
		workLeaders:(NSMutableArray *) someWorkLeaders
	  attachedFiles:(NSMutableArray *) someAttachedFiles
	 historyEntries:(NSMutableArray *) someHistoryEntries
		timeReports:(NSMutableArray *) someTimeReports
	checklistPoints:(NSMutableArray *) someChecklistPoints
		  timeTypes:(NSMutableArray *) theTimeTypes
		statusTypes:(NSMutableArray *) theStatusTypes
	  priorityTypes:(NSMutableArray *) thePriorityTypes
{
	if (self = [super init])
	{
		self.workID = aWorkID;
		self.description = aDescription;
		self.checklistType = aChecklistType;
		self.status = aStatus;
		self.priority = aPriority;
		self.customer = aCustomer;
		self.entryDate = anEntryDate;
		self.endDate = anEndDate;
		self.address = anAddress;
		self.employees = someEmployees;
		self.contactPersons = someContactPersons;
		self.workLeaders = someWorkLeaders;
		self.attachedFiles = someAttachedFiles;
		self.historyEntries = someHistoryEntries;
		self.addedHistoryEntries = [NSMutableArray array];
		self.updatedHistoryEntries = [NSMutableArray array];
		self.timeReports = someTimeReports;
		self.addedTimeReports = [NSMutableArray array];
		self.updatedTimeReports = [NSMutableArray array];
		self.checklistPoints = someChecklistPoints;
		self.timeTypes = theTimeTypes;
		self.statusTypes = theStatusTypes;
		self.priorityTypes = thePriorityTypes;
	}
	return self;
}

- (id) init
{
	if (self = [super init])
	{
		self.workID = 0;
		self.description = @"";
		self.checklistType = @"Ordinarie";
		self.status = @"Inaktiv";
		self.priority = @"Medel";
		self.customer = @"Dummy";
		self.entryDate = nil;
		self.endDate = nil;
		self.address = [[WOAddress alloc] init];
		self.employees = [NSMutableArray array];
		self.contactPersons = [NSMutableArray array];
		self.workLeaders = [NSMutableArray array];
		self.attachedFiles = [NSMutableArray array];
		self.historyEntries = [NSMutableArray array];
		self.addedHistoryEntries = [NSMutableArray array];
		self.updatedHistoryEntries = [NSMutableArray array];
		self.timeReports = [NSMutableArray array];
		self.addedTimeReports = [NSMutableArray array];	
		self.updatedTimeReports = [NSMutableArray array];
		self.checklistPoints = [NSMutableArray array];
		self.timeTypes = [NSMutableArray array];
		self.statusTypes = [NSMutableArray array];
		self.priorityTypes = [NSMutableArray array];
	}
	return self;
}

- (void) dealloc
{
	[description release];
	[checklistType release];
	[status release];
	[priority release];
	[customer release];
	[entryDate release];
	[endDate release];
	[address release];
	[employees release];
	[contactPersons release];
	[workLeaders release];
	[attachedFiles release];
	[historyEntries release];
	[addedHistoryEntries release];
	[timeReports release];
	[addedTimeReports release];
	[checklistPoints release];	
	[timeTypes release];
	[statusTypes release];
	[priorityTypes release];	

	[super dealloc];
}

@end
